Page({
  data: {
    houseList: [],
    houseId: '',
    houseName: '',
    currentDate: new Date().getTime(),
    houseLayerVisible: false,
    repairLayerVisible: false,
    dateLayerVisible: false,
    repairItem: [{
      name: '水路卫浴'
    }, {
      name: '电路灯具'
    }, {
      name: '管道疏通'
    }, {
      name: '开锁换锁'
    }],
    attachment: [{
        url: '/repair_pkg/static/uploads/attachment.jpg'
      },
      {
        url: '/repair_pkg/static/uploads/attachment.jpg'
      },
    ],
  },
  onLoad() {
    // 获取维修项目
    this.getHouseList()
    // this.getRepairItem()

  },
  async getHouseList() {
    // 调用接口
    const {
      code,
      data: houseList
    } = await wx.http.get('/house')
    // 检测接口是否调用成功
    if (code !== 10000) return wx.utils.toast()
    // 渲染数据
    this.setData({
      houseList
    })
  },
  selectHouseInfo(ev) {
    // 数据渲染
    this.setData({
      houseId: ev.detail.id,
      houseName: ev.detail.name,
    })
  },
  openHouseLayer() {
    this.setData({
      houseLayerVisible: true
    })
  },
  closeHouseLayer() {
    this.setData({
      houseLayerVisible: false
    })
  },
  openRepairLayer() {
    this.setData({
      repairLayerVisible: true
    })
  },
  closeRepairLayer() {
    this.setData({
      repairLayerVisible: false,
    })
  },

  openDateLayer() {
    this.setData({
      dateLayerVisible: true
    })
  },
  closeDateLayer() {
    this.setData({
      dateLayerVisible: false
    })
  },
  goList() {
    wx.reLaunch({
      url: '/repair_pkg/pages/list/index',
    })
  },
})